//
//  TradeListModel.m
//  BlackBambooCM-OC
//
//  Created by DKang on 2018/12/7.
//  Copyright © 2018年 ucanmax. All rights reserved.
//

#import "TradeListModel.h"

@implementation TradeListModel
- (instancetype)initWithDic:(NSDictionary *)dict {
    self = [super init];
    if (self) {
        _goodsName = dict[@"goodsName"];
        _barcodeId = dict[@"barcodeId"];
        _goodsBrandId = dict[@"goodsBrandId"];
        _goodsId = dict[@"goodsId"];
        _goodsBrandId = dict[@"goodsGuidingPrice"];
        _goodsProperty = dict[@"goodsProperty"];
        _goodsState = dict[@"goodsState"];
        _goodsTypeId = dict[@"goodsTypeId"];
        _meteringUnitGroupId = dict[@"meteringUnitGroupId"];
    }
    return self;
}

/**
 获取商品列表
 */
+ (void)getTradeList:(NSInteger)pageIndex goodsName:(NSString *)goodsName array:(NSMutableArray *)mutArray complete:(void (^)(NSMutableArray * _Nonnull))complete onFailure:(void (^)(NSString * _Nonnull))failure {
    [[WYNetwork sharedWYNetwork] getproductList:pageIndex goodsName:goodsName success:^(id responseObject) {
        if(pageIndex == 1){
            [mutArray removeAllObjects];
        }
        NSDictionary *page = responseObject[@"page"];
        NSArray *list = page[@"list"];
        if(list){
            for (NSDictionary *dict in list) {
                TradeListModel *model = [[TradeListModel alloc]initWithDic:dict];
                [mutArray addObject:model];
            }
        }
        complete(mutArray);
    } failure:^(NSString *error) {
        failure(error);
    }];
}

@end
